<?php
class Admin_LocationController extends Zend_Controller_Action
{
	private $_params;
	private $_auth;
	private $_acl;
    public function init(){
        $this->_params      = $this->_request->getParams();
        $this->_acl         = new My_Acl();
        $this->view->acl    = $this->_acl;
        $this->_auth        = $this->_acl->checkAllowed();
        $this->view->auth   = $this->_auth;
    }
    public function getdistrictAction(){
        $province = $this->_request->getParam('province');                    
        $models=new Admin_Model_District;
        $district=$models->getDataByProvince($province)->toArray();
        $districtList=array();
        foreach($district as $dis){
            $districtList[$dis['districtid']]=$dis['name'];
        }             
        echo json_encode($districtList,JSON_UNESCAPED_UNICODE);        
        $this->_helper->layout()->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);        
    }
    public function getwardAction(){
        $district = $this->_request->getParam('district');                    
        $models=new Admin_Model_Ward;
        $ward=$models->getDataByDistrict($district)->toArray();
        $wardList=array_column($ward,'name','wardid');
        //foreach($ward as $wa){
            //$wardList[$wa['wardid'].'_'.$wa['type']]=$wa['name'];
        //}                
        echo json_encode($wardList,JSON_UNESCAPED_UNICODE);        
        $this->_helper->layout()->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);        
    }
}


